package com.cgbl.cg.adapter

import com.cgbl.cg.R
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.robot.base.model.CustomerItemInfo
import com.robot.base.utils.pic.ImageLoaderUtils

class ProjectAdapter :
    BaseQuickAdapter<CustomerItemInfo, BaseViewHolder>(R.layout.app_item_project) {

    override fun convert(holder: BaseViewHolder, item: CustomerItemInfo) {
        holder.setText(R.id.tv_time, item.startTime)
            .setText(R.id.tv_project_name, item.itemName)
            .setText(R.id.tv_project_price, item.duesPrice)
        when (item.status) {
            //0审核中，1：待启动，2：已付款，3：开发中，4：已完成，5，已结算，6：审核拒绝
            "0" -> {
                holder.setText(R.id.tv_project_state, "审核中")
                    .setText(R.id.tv_project_state2, "审核中")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_audit
                )
            }
            "1" -> {
                holder.setText(R.id.tv_project_state, "待启动")
                    .setText(R.id.tv_project_state2, "待启动")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_audit
                )
            }
            "2" -> {
                holder.setText(R.id.tv_project_state, "已付款")
                    .setText(R.id.tv_project_state2, "已付款")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_audit
                )
            }
            "3" -> {
                holder.setText(R.id.tv_project_state, "开发中")
                    .setText(R.id.tv_project_state2, "开发中")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_develop
                )
            }
            "4" -> {
                holder.setText(R.id.tv_project_state, "已完成")
                    .setText(R.id.tv_project_state2, "已完成")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_complete
                )
            }
            "5" -> {
                holder.setText(R.id.tv_project_state, "已结算")
                    .setText(R.id.tv_project_state2, "已结算")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_close
                )
            }
            "6" -> {
                holder.setText(R.id.tv_project_state, "审核拒绝")
                    .setText(R.id.tv_project_state2, "审核拒绝")
                holder.setBackgroundResource(
                    R.id.tv_project_state,
                    R.drawable.app_bg_project_state_audit
                )
            }
        }


        ImageLoaderUtils.displayRound(
            context,
            holder.getView(R.id.iv_project_img),
            item.itemFile,
            8
        )
    }
}